<template>
  <div>
    <fwb-modal id="modal" size="md" @close="close">
      <template #header>
        <div class="flex items-center text-[14px] s4k:text-[28px] s4k:ml-5 font-medium leading-tight"
          style="color: #9ca3af">Add Camera Manually</div>
      </template>
      <template #body>
        <div class="mt-3 s4k:mt-2" style="border: 1px 0 1px 0 solid #4b5563">
          <h1 class="leading-none text-[18px] s4k:text-[36px] font-bold text-[var(--theme-font-color)] ">Add New Camera
          </h1>
          <div class="text-xs font-medium text-[var(--theme-font-color)] mt-4 mb-2 s4k:text-[24px] s4k:mt-8 s4k:mb-4">IP
            Address</div>
          <fwb-input v-model="address" placeholder id="address" style="width: 100%"></fwb-input>
          <div class="flex items-center justify-between">
            <div class="w-[171px] s4k:w-[342px]">
              <div
                class="text-xs font-medium text-[var(--theme-font-color)] mt-4 mb-2 s4k:text-[24px] s4k:mt-8 s4k:mb-4">
                Transfer Protocol</div>
              <!-- <fwb-input v-model="address" placeholder id="address" style="width: 100%"></fwb-input> -->
              <fwb-dropdown :text="textUrl" id="dropdown">
                <fwb-list-group>
                  <fwb-list-group-item @click.stop="clickTextUrl('POST')">POST</fwb-list-group-item>
                  <fwb-list-group-item @click="clickTextUrl('PUT')">PUT</fwb-list-group-item>
                  <fwb-list-group-item @click="clickTextUrl('GET')">GET</fwb-list-group-item>
                  <fwb-list-group-item @click="clickTextUrl('Hearder')">Hearder</fwb-list-group-item>
                </fwb-list-group>
              </fwb-dropdown>
            </div>
            <div class="w-[171px] s4k:w-[342px] ml-[10px]">
              <div
                class="text-xs font-medium text-[var(--theme-font-color)] mt-4 mb-2 s4k:text-[24px] s4k:mt-8 s4k:mb-4">
                Port</div>
              <fwb-input v-model="address" placeholder id="address" style="width: 100%"></fwb-input>
            </div>
          </div>
          <div class="text-xs font-medium text-[var(--theme-font-color)] mt-4 mb-2 s4k:text-[24px] s4k:mt-8 s4k:mb-4">
            Camera Username</div>
          <fwb-input v-model="address" placeholder id="address" style="width: 100%"></fwb-input>
          <div class="text-xs font-medium text-[var(--theme-font-color)] mt-4 mb-2 s4k:text-[24px] s4k:mt-8 s4k:mb-4">
            Password</div>
          <fwb-input v-model="address" placeholder id="address" style="width: 100%"></fwb-input>
          <div class="text-xs font-medium text-[var(--theme-font-color)] mt-4 mb-2 s4k:text-[24px] s4k:mt-8 s4k:mb-4">
            Group</div>
          <el-tree-select v-model="treeValue" :data="treeData" check-strictly :render-after-expand="false"
            style="width: 100%" :teleported="false" class="select_box" />
        </div>
      </template>
      <template #footer>
        <div class="flex justify-start">
          <button id="dropdownDefaultButton" data-dropdown-toggle="dropdown"
            class="w-[160px] h-[41px] s4k:w-[320px] s4k:h-[82px] s4k:text-[28px] s4k:px-10 s4k:py-5 text-white bg-[#1C64F2] focus:ring-4 font-medium rounded-lg text-sm px-5 py-2.5 text-center inline-flex items-center justify-center"
            type="button" @click="isAddCamerShow = !isAddCamerShow">
            <span class="text-md text-white font-Medium font-[400] s4k:text-[28px]">Add Camera</span>
          </button>
        </div>
      </template>
    </fwb-modal>
  </div>
</template>
<script>
import { onMounted, reactive, ref, defineEmits } from "vue";
import {
  FwbInput,
  FwbButton,
  FwbModal,
  FwbDropdown,
  FwbListGroup,
  FwbListGroupItem
} from "flowbite-vue";
import { defineComponent } from "vue";

export default defineComponent({
  name: "ModalManually"
});
</script>
<script setup>
const addressOptional = ref("");
const address = ref("");
const account = ref("");
const password = ref("");
const cameraIndex = ref(1);
const cameraList = ref([]);
const isAddCamerShow = ref(false);
const isAnimation = ref(false);
const iscamerTable = ref(false);
const tableCount = ref(0);
const textUrl = ref("TCP");
//
const Fun = defineEmits(["close"]);

const close = () => {
  Fun("close", false);
};
//
const clickTextUrl = val => {
  textUrl.value = val;
};
const treeValue = ref()
const treeData = [
  {
    value: '1',
    label: 'Level one 1',
    children: [
      {
        value: '1-1',
        label: 'Level two 1-1',
        children: [
          {
            value: '1-1-1',
            label: 'Level three 1-1-1',
          },
        ],
      },
    ],
  },
  {
    value: '2',
    label: 'Level one 2',
    children: [
      {
        value: '2-1',
        label: 'Level two 2-1',
        children: [
          {
            value: '2-1-1',
            label: 'Level three 2-1-1',
          },
        ],
      },
      {
        value: '2-2',
        label: 'Level two 2-2',
        children: [
          {
            value: '2-2-1',
            label: 'Level three 2-2-1',
          },
        ],
      },
    ],
  },
]
</script>
<style lang="scss" scoped>
#modal {
  :deep(.max-w-md) {
    width: 400px !important;
    height: 526px !important;
    z-index: 999 !important;

    button {
      cursor: pointer;

      &:hover {
        background: var(--theme);
      }

      svg {
        color: #6B7280;
      }
    }

    #dropdown {
      position: relative;

      .divide-y {
        position: absolute;
        height: 100px;
        top: 40px !important;
      }
    }
  }

  :deep(.bg-white) {
    border: 1px solid var(--grid);
    background-color: var(--theme) !important;
    z-index: 999 !important;
  }

  :deep(.p-6) {
    z-index: 999 !important;
    padding: 21px !important;
    border-top: 1px solid var(--grid);
  }
}

#address {
  padding: 0;

  :deep(input) {
    padding-top: 0;
    padding-bottom: 0;
    height: 36px;
    background-color: var(--theme);
    border: solid var(--grid) 1px;
    font-size: 14px;
    font-family: Medium;
    color: var(--theme-font-color);

    &:focus {
      box-shadow: inset 0 0;
    }
  }
}

button {
  box-shadow: none !important;
}

:deep(.el-select__wrapper){
  // border: solid red;
  height: 36px;
  box-shadow: none;
  background-color: var(--theme);
    border: solid var(--grid) 1px;
    font-size: 14px;
    font-family: Medium;
    color: var(--theme-font-color);

    &:focus {
      box-shadow: inset 0 0;
    }
}
:deep(.el-tree-node__content) {
  // background: gray;
  background: var(--theme) !important;
  height: 50px !important;
  border-bottom: solid var(--theme) 1px !important;
  &:hover{
    background: var(--theme-right) !important;
  }
}
@media screen and (min-width: 2560px) {
  #modal {
    :deep(.max-w-md) {
      transform: scale(1.3);

      #dropdown {
        position: relative;

        :deep(button) {
          font-size: 20px !important;
        }

        .divide-y {
          position: absolute;
          height: 160px;
          top: 40px !important;

          li {
            font-size: 14px;
            height: 40px;
          }
        }
      }
    }
  }
}

@media screen and (min-width: 3840px) {
  #modal {
    :deep(input) {
      padding: 15px 10px;
      height: 36px;
      background-color: var(--theme);
      border: solid var(--grid) 1px;
      font-size: 28px;
      font-family: Medium;
      color: var(--theme-font-color);

      &:focus {
        box-shadow: inset 0 0;
      }
    }
  }
  :deep(.el-select__wrapper){
    border-radius: 10px;
    padding: 0 20px;
    height: 72px;
    font-size: 28px;
    svg{
      transform: scale(2);
    }
  }
}

#dropdown {
  :focus {
    box-shadow: none;
  }

  :deep(button) {
    width: 171px;
    height: 36px;
    border: 1px solid var(--grid);
    background-color: var(--theme) !important;
    cursor: pointer;

    // :before {
    //   content: "";
    // }
    // span {
    //   display: none;
    // }
    svg {
      position: absolute;
      right: 3%;
      top: 50%;
      transform: translateY(-50%);
      width: 15px;
      height: 15px;
      color: var(--svg);
    }
  }

  :deep(.ml-2) {
    display: flex;
    align-items: center;
  }

  :deep(.rounded) {
    overflow: hidden;
  }

  :deep(ul) {
    width: 171px;
    color: var(--theme-font-color);
    border: none !important;
    border-radius: 0;

    // overflow: hidden;
    li:hover {
      cursor: pointer !important;
      background-color: var(--grid);
    }
  }

  :deep(li) {
    width: 171px;
    box-sizing: border-box;
    font-size: 14px;
    display: inline-block;
    border-bottom: 1px solid var(--grid);
  }

  :deep(li):last-child {
    border-bottom: none;
  }

  :deep(span) {
    display: inline-block;
    width: 130px;
    color: var(--theme-font-color);
    font-size: 14px !important;
    text-align: left;
    font-weight: normal;
  }
}

#modal {
  :deep(.max-w-md) {
    width: 400px !important;
    height: 526px !important;

    #dropdown {
      .divide-y {
        bottom: -285px !important;
      }
    }
  }

  :deep(.bg-white) {
    border: 1px solid var(--grid);
    background-color: var(--theme) !important;
  }

  :deep(.p-6) {
    padding: 21px !important;
    border-top: 1px solid var(--grid);
  }
}

@media screen and (min-width: 3840px) {
  #modal {
    :deep(.max-w-md) {
      width: 800px !important;
      height: 1052px !important;
      max-width: 1200px !important;

      #dropdown {
        position: relative;

        :deep(button) {
          font-size: 20px !important;
        }

        span {

          font-size: 20px !important;
        }

        .divide-y {
          position: absolute;
          height: 200px;
          top: 80px !important;

          li {
            font-size: 20px;
            height: 50px;
          }
        }
      }

      .p-4 {
        padding-left: 6px;
        padding-right: 6px;
      }
    }

    :deep(.bg-white) {
      border: 2px solid var(--grid);
      background-color: var(--theme) !important;
    }

    :deep(.p-6) {
      padding: 42px !important;
      border-top: 2px solid var(--grid);
    }

    :deep(.w-5) {
      width: 40px;
      height: 40px;
    }
  }

  #dropdown {
    :focus {
      box-shadow: none;
    }

    :deep(button) {
      width: 342px;
      height: 68px;
      padding: 16px 32px;
      border: 1px solid var(--grid);
      background-color: var(--theme) !important;
      cursor: pointer;

      // :before {
      //   content: "";
      // }
      // span {
      //   display: none;
      // }
      svg {
        width: 32px;
        height: 32px;
      }
    }

    :deep(.ml-2) {
      display: flex;
      align-items: center;
    }

    :deep(ul) {
      width: 342px;
      color: var(--theme-font-color);
      border: none !important;
      // border-radius: 16px;
      overflow: hidden;

      &:focus {
        cursor: pointer !important;
        background-color: var(--grid);
      }
    }

    :deep(li) {
      width: 342px;
      height: 68px;
      box-sizing: border-box;
      font-size: 28px;
      display: inline-block;
      border-bottom: 1px solid var(--grid);
    }

    :deep(li):last-child {
      border-bottom: none;
    }

    :deep(span) {
      display: inline-block;
      width: 300px;
      font-size: 28px !important;
      text-align: left;
      font-weight: normal;
    }
  }
}

#camerasModal {
  :deep(.max-w-md) {
    width: 1121px !important;
    height: 688px !important;
    max-width: 1121px !important;
  }

  :deep(.bg-white) {
    border: 1px solid var(--grid);
    background-color: var(--theme) !important;
  }

  :deep(.p-6) {
    padding: 0 !important;
    border-top: 1px solid var(--grid);
  }
}
</style>
<style lang="scss">
.el-select__popper.el-popper{
  background: var(--theme-hover) !important;
}
.el-select__popper.el-popper{
  border: #4B5563 solid 1px;
}
.el-select-dropdown__item {
  color: var(--theme-font-color) !important; 
  background: var(--theme-hover) !important;
}
.el-select-dropdown__list{
  padding: 0;
}
// .el-popper__arrow{
//   border-bottom-color: transparent !important;
//   border-style: none !important;
// }
/* 隐藏 el-popper__arrow 伪元素的尖角 */
.el-popper__arrow {
  display: none; /* 隐藏箭头 */
}

/* 如果你想要去掉尖角而不是完全隐藏箭头，可以设置以下样式 */
.el-popper__arrow::before {
  border: none; /* 去掉伪元素的边框 */
  content: ''; /* 清除默认的内容 */
}
// @media screen and (min-width: 3840px) {
//   .el-select__popper.el-popper{
//     background: var(--theme-hover) !important;
//   }
//   .el-select__popper.el-popper{
//     border: solid var(--theme-hover);
//   }
//   .el-select-dropdown__item {
//     color: var(--theme-font-color) !important; 
//     background: var(--theme-hover) !important;
//   }
//   .el-select-dropdown__list{
//     height: 100px !important;
//     padding: 0;
//   }
// }
</style>